// sysbase.h - Copyright (C) 2013 Willow Schlanger. All rights reserved. See univm_license.txt.
// ============================================================================================

#ifndef l_sysbase_h__infrared_isb__included
#define l_sysbase_h__infrared_isb__included

#include <stddef.h>
#include <string.h>
#include <string>

#include <boost/pool/pool.hpp>
#include <boost/pool/pool_alloc.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/locks.hpp>
#include <boost/locale.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/tokenizer.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/bind.hpp>
#include <boost/ref.hpp>

namespace infrared_sysbase
{

// Unsigend types.
typedef unsigned char U1;
typedef unsigned short U2;
typedef unsigned int U4;
typedef unsigned long long U8;

// Signed types.
typedef signed char S1;
typedef signed short S2;
typedef signed int S4;
typedef signed long long S8;

// Some platforms may have a 32-bit std::size_t even in 64-bit mode.
// Our own usize_t and spttrdiff_t are always 64-bits in size.
typedef U8 usize_t;
typedef S8 sptrdiff_t;

using boost::pool_allocator;
using boost::fast_pool_allocator;

// 'ustring' is an efficient replacement for 'std::string'. It's designed to hold UTF-8
// characters always, and uses pool_allocator instead of the default allocator.
typedef std::basic_string<char, std::char_traits<char>, pool_allocator<char> > ustring;
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, pool_allocator<wchar_t> > uwstring;
typedef std::basic_string<U2, std::char_traits<U2>, pool_allocator<U2> > utf16string;

/*
Begin sample code on how to us threads.
---
class my_thread_class  {
	critsec_t *pCs;
	int *pCount;
public:
 	my_thread_class(critsec_t *pCsT, int *pCountT) :
		pCs(pCsT),
		pCount(pCountT)
 	{
 	}
		
	void operator()()
	{
		autolock_t lock(*pCs);
		(*pCount)++;
	}
};

int main(int arc, char *argv[])
{
	critsec_t cs;
	int counter = 0;
	
	// Start new thread.
	my_thread_class tc(&cs, &counter);
	boost::thread x(tc), y(tc);
	
	// Wait for threads to exit.
	x.join();
	y.join();
	std::cout << "Count is now " << counter << std::endl;

	return 0;
}
---
End sample code.
*/

using boost::thread;
typedef boost::mutex critsec_t;
typedef boost::lock_guard<critsec_t> autolock_t;

}	// namespace infrared_sysbase

#include "objects.h"

#endif	// l_sysbase_h__infrared_isb__included
